package ua.at.tsvetkov.samizdat.adapters;

import ua.at.tsvetkov.samizdat.R;
import ua.at.tsvetkov.samizdat.data.BookColor;
import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class AdtBookColors extends BaseAdapter {

	private LayoutInflater	mInflater;

	public AdtBookColors(Activity context) {
		this.mInflater = LayoutInflater.from(context);
	}

	@Override
	public int getCount() {
		return BookColor.colors.length;
	}

	@Override
	public Object getItem(int position) {
		return BookColor.colors[position];
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		convertView = mInflater.inflate(R.layout.adt_book_color, null);
		TextView holder = (TextView) convertView.findViewById(R.id.AdtBookColorText);
		convertView.setBackgroundResource(BookColor.colors[position].background);
		holder.setText(BookColor.colors[position].name);
		holder.setTextColor(BookColor.colors[position].textColor);
		return convertView;

	}

}
